﻿using System;

namespace diantou.web.enterprise
{
    /// <summary>
    /// 发送通知
    /// </summary>
    /// <typeparam name="viewType"></typeparam>
    abstract class sendMessage<viewType> : examPermissionView<viewType>
        where viewType : sendMessage<viewType>
    { 
        /// <summary>
        /// 默认空模版
        /// </summary>
        private static readonly diantou.examDataAccess.enterpriseMail nullMail = new diantou.examDataAccess.enterpriseMail { IsEmail = true, Name = "请选择", Title = string.Empty, Content = string.Empty };
        /// <summary>
        /// 考试
        /// </summary>
        [fastCSharp.emit.webView.clearMember]
        protected diantou.examDataAccess.exam exam;
        /// <summary>
        /// 考试用户
        /// </summary>
        [fastCSharp.emit.webView.clearMember]
        protected diantou.examDataAccess.examUser user;
        /// <summary>
        /// 邮件模版
        /// </summary>
        protected diantou.examDataAccess.enterpriseMail mail
        {
            get { return nullMail; }
        }
        /// <summary>
        /// 邮件模板集合
        /// </summary>
        protected diantou.examDataAccess.enterpriseMail[] mails
        {
            get { return examDataAccess.tcpCall.enterpriseMail.get(currentUserId, true); }
        }
        /// <summary>
        /// 短信模板集合
        /// </summary>
        protected diantou.examDataAccess.enterpriseMail[] sms
        {
            get { return examDataAccess.tcpCall.enterpriseMail.get(currentUserId, false); }
        }

    }
    /// <summary>
    /// 发送通知
    /// </summary>
    [fastCSharp.code.cSharp.webView(IsPage = false, IsPool = true)]
    partial class sendMessage : sendMessage<sendMessage>
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        private bool loadView(int userId)
        {
            user = diantou.examDataAccess.clientCache.GetExamUser(userId, currentUser);
            if (user != null)
            {
                exam = diantou.examDataAccess.clientCache.Exam[user.ExamId];
                if (exam != null) return true;
            }
            AjaxResponse(webConfig.NotFound404);
            return false;
        }
    }
}
